sinclude ../scripts/xbuild/env.mk

# we have build dir, so need double last level
LINK_ROOT_PATH		:= ../..
COMPILE_ROOT_PATH	:= ..

ifeq ($(ARCH),x86) # x86

CC			:= $(CROSS_COMPILE)gcc -m32
AS			:= $(CROSS_COMPILE)gcc -m32
LD			:= $(CROSS_COMPILE)ld -m elf_i386

MCFLAGS		:= -march=i386
else ifeq ($(ARCH),riscv64) # riscv64

MCFLAGS		:= -march=rv64imafdc -mabi=lp64d -mcmodel=medany -DNX_CPU_64BIT
else
$(error unsupported arch!)
endif


X_CFLAGS	:= $(MCFLAGS) -fno-builtin -fno-stack-protector 
X_CFLAGS	+= -nostdlib -nostdinc -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99

X_ACFLAGS	+= $(MCFLAGS) -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99

X_LDFLAGS 	:= -no-pie -n
X_LDFLAGS 	+= -nostdlib
X_LDFLAGS 	+= -T $(LINK_ROOT_PATH)/ldscripts/$(ARCH).ld

# sdk for libs
LINK_SDK_DIR		:= $(LINK_ROOT_PATH)/sdk
COMPILE_SDK_DIR		:= $(COMPILE_ROOT_PATH)/sdk

X_INCDIRS	:= $(COMPILE_SDK_DIR)/include
X_LIBDIRS	:= $(LINK_SDK_DIR)/lib

X_CLEAN		:= build/

# MODULE		+= libnxos
